@extends('manage.layout')

@section('content')
    <div class="content">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                统计登录页
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                <li><a href="#">SALE DAY COUNT</a></li>
            </ol>
            <div class="input-group margin">
                <form action="{{ url('/info/saleDayInfo') }}" method="get" >
                    {{ csrf_field() }}
                    <div class="input-group" style="float: left">
                        <div class="input-group-addon">
                            <i class="fa fa-calendar"></i>
                        </div>
                        <input type="text" class="form-control pull-right" id="reservation" name="t_time" value="{{$t_time}}">
                    </div>
                    <input type="submit" class="btn btn-info btn-flat" value="Go!" style="float: left;margin-right: 10px;">
                    <input type="button" class="btn btn-block btn-danger" value="下载结果集" style="width: 100px" id="down_csv">
                </form>
            </div>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">销售日报统计</h3>
                        </div>
                        <!-- /.box-header -->
                        <div class="box-body">
                            <table class="table table-bordered table-hover"  style=" text-align: center;">
                                <tr>
                                    <th style=" text-align: center;">本次跟进时间</th>
                                    <th style=" text-align: center;">部门</th>
                                    <th style=" text-align: center;">部门主管</th>
                                    <th style=" text-align: center;">销售人员</th>
                                    <th style=" text-align: center;">联系人</th>
                                    <th style=" text-align: center;">联系方式</th>
                                    <th style=" text-align: center;">跟进方式</th>
                                    <th style=" text-align: center;">项目状态</th>
                                    <th style=" text-align: center;">客户名称</th>
                                    <th style=" text-align: center;">订购产品</th>
                                    <th style=" text-align: center;">预计金额</th>
                                    <th style=" text-align: center;">销售反馈</th>
                                    <th style=" text-align: center;">客户创建时间</th>
                                    <th style=" text-align: center;">首次跟进时间</th>
                                </tr>
                                @foreach($follow_list as $p)
                                <tr>
                                    <td>{{$p['create_time']}}</td>
                                    <td>{{$p['op_depart_info']->name}}</td>
                                    <td>{{$p['department_admin']}}</td>
                                    <td>{{$p['op_info']->nickname}}</td>
                                    <td>{{$p['first_info']->first_name}}</td>
                                    <td>{{$p['first_info']->first_phone}}</td>
                                    <td>{{$p['form_str']}}</td>
                                    <td>{{$p['project_info']->stage_str}}</td>
                                    <td>{{$p['first_info']->company}}</td>
                                    <td>
                                    @foreach($p['project_info']['product_id_str'] as $v)
                                    {{$v}}&nbsp;
                                    @endforeach
                                    </td>
                                    <td>{{$p['project_info']->future_price}}</td>
                                    <td>{{$p['result']}}</td>
                                    <td>{{$p['first_info']->create_time}}</td>
                                    <td>{{$p['project_info']->next_visit}}</td>
                                </tr>
                                @endforeach
                                {{--<tr>--}}
                                    {{--<td>今日新增数</td>--}}
                                    {{--<td>{{$info['clientTodayCount']}}</td>--}}
                                    {{--<td>{{$info['projectTodayCount']}}</td>--}}
                                    {{--<td>{{$info['orderTodayCount']}}</td>--}}
                                {{--</tr>--}}
                            </table>
                        </div>
                        <!-- /.box -->
                        {{ $follow_list->appends(['t_time'=>$t_time,'count'=>$count])->links() }}
                    </div>
                    <!-- /.row -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
@stop
@section('script')
    <script>
        $(function () {
            $('#reservation').daterangepicker(
                {locale:{format: 'YYYY/MM/DD'}}
            );
        });
        $("#down_csv").click(function () {
            var reservation = $("#reservation").val();
            window.location.href = "/info/saleDayInfo?csv_flag=10&t_time="+reservation;
        });
        function deleteRole(id) {
            layer.confirm('删除后不可恢复，是否继续?', {
                btn:['确定','取消']
            },function() {
                $.ajax({
                    url: '/system/role/delRole',
                    type: "GET",
                    data: {id:id},
                    dataType: "json",
                    success: function(res) {
                        console.log(res);
                        if(res.error == 0) {
                            window.location.href = "/system/role";
                            layer.msg(res.msg)
                        }
                        else {
                            layer.msg(res.msg)
                        }
                    }
                });
            });
        }
        //禁用,启用
        function setStatus(id,status) {
            $.ajax({
                url: '/system/role/setStatus',
                type: "GET",
                data: {id:id,status:status},
                dataType: "json",
                success: function(res) {
                    console.log(res);
                    if(res.error == 0) {
                        window.location.href=window.location.href;
                        layer.msg(res.msg, {time:1500, icon:1})
                    }
                    else {
                        layer.msg(res.msg, {time:1500, icon:2})
                    }
                }
            });
        }
    </script>
@stop
